class Person:
    def __init__(self, name, age):
        """
        构造方法
        :param name:
        :param age:
        """
        self.name = name
        self.age = age

    def show_name(self):
        """
        成员方法
        :return:
        """
        print('名称' + self.name)


class Teacher:
    def __init__(self, name, age, school):
        self.name = name
        self.age = age
        self.school = school

    def show_name(self):
        print('老师名称: ' + self.name)


class Women(Teacher, Person):
    """
    类多重继承如果出现父类方法名相同的情况
    会调用第一个父类的方法
    """
    def __init__(self, name, age, school='第一中学'):
        super().__init__(name, age, school)


women = Women('小明', 23)
women.show_name()


class Vector:
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def __str__(self):
        """
        类似于Java中类的 toString() 方法
        :return:
        """
        return 'Vector123 (%d, %d)' % (self.a, self.b)

    def __add__(self, other):
        """
        '+'的运算符重载
        :param other: 其他Vector对象
        :return: 实例对象
        """
        return Vector(self.a + other.a, self.b + other.b)

    def prt(self):
        print(self.a)
        print(self.b)


v1 = Vector(2, 10)
v2 = Vector(5, -2)
v3 = v1 + v2
v3.prt()
print(v3)

# 最后一行防止警告出现
